﻿using System;
using System.Collections.Generic;
using System.Web;

/// <summary>
/// Summary description for ClassName
/// </summary>
public class CustomerCashCard
{
    public CustomerCashCard()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    
    public string CustomerID{get;set;}
    public string CustomerClassification{get;set;}
    public string CustomerStatus{get;set;}
    public string Country{get;set;}
    public string Gender{get;set;}
    public string Nationality{get;set;}
    public DateTime? Bdate{get;set;}
    public string PlaceOfBirth{get;set;}
    public string IDNumber{get;set;}
    public string IDType{get;set;}
    public string SrcOfFunds{get;set;}
    public string Employment{get;set;}
    public string Employer{get;set;}
    public string NatureOfWork{get;set;}
    public string CashCardAppNo{get;set;}
    public DateTime? ApplicationDate{get;set;}
    public string CashCardStatus{get;set;}
    public DateTime? CashCardStatusDate{get;set;}
    public string DocumentStatus{get;set;}
    public string CashCardNo{get;set;}
    public string CashCardType{get;set;}
    public string PartnerBank{get;set;}
    public DateTime? StatusDate{get;set;}
    public string NameOnCard{get;set;}
    public DateTime? CardExpDate{get;set;}
    public string CardDelStatus{get;set;}
    public DateTime? DelStatusDate{get;set;}
    public string Remarks{get;set;}
    public string DelRemarks{get;set;}
    public string CardDelCourier{get;set;}
    public DateTime? DelDate{get;set;}
    public DateTime? DateCreated{get;set;}
    public DateTime? DateUpdated{get;set;}
    
    public static dynamic GetNextCallCardID(string custID){
        var sql = "SELECT Max(CCSequence) as NextSeq FROM Uniques WHERE CustomerID=@0";
        object[] param = new object[1]{custID};
        var query = DBManager.Query(sql,param);
        int nextID=0;
        foreach(var id in query){
            nextID=(int)id.NextSeq;
            
        }
        var seq = string.Format("{0}-{1:d2}",custID,++nextID);
        
        var usql= "UPDATE Uniques SET CCSequence=@0 WHERE CustomerID=@1";
        object[] param2 = new object[2]{nextID,custID};
        var uquery = DBManager.Execute(usql,param2);
        
        
        return seq;
    }
}
